//https://leetcode.cn/problems/linked-list-cycle/submissions/677561879/?envType=study-plan-v2&envId=top-interview-150

class Solution {
public:
    vector<ListNode*> arr;

    bool isin(ListNode* node)
    {
        for (auto& e : arr)
        {
            if (e == node)
                return true;
        }
        return false;
    }

    bool hasCycle(ListNode* head)
    {
        ListNode* node = head;
        while (node)
        {
            if (!isin(node))
                arr.push_back(node);
            else
                return true;

            node = node->next;
        }
        return false;
    }
};